﻿using UnityEngine;
using System.Collections;

public class Cam : MonoBehaviour {

	public GameObject target;
	public float z = -10;

	// Update is called once per frame
	void Update () {

		// Onko kohde olemassa?
		if(target != null)
		{
			// liikkuu kohdetta kohti 
			transform.position -= (transform.position - target.transform.position)/40;

			// pakotetaan z-arvo sellaseks kun se halutaan
			transform.position = new Vector3(transform.position.x, transform.position.y, z);
		}
	}
}
